package cn.zhoutingrui.pethome.mylistener;

import cn.zhoutingrui.pethome.system.permission.service.IPermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.rmi.server.ServerCloneException;

@WebListener
@Slf4j
public class PermissionScanInitListener implements ServletContextListener {
    @Autowired
    private IPermissionService permissionService;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                log.info("权限初始化开始");
                permissionService.scanPermission();
            }
        }).start();
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        ServletContextListener.super.contextDestroyed(sce);
    }
}
